<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 17, 2010
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/formdepartment.php
 ^
 * Description: template view for form department
 ^
 * History:		NONE
 ^
 */


defined('_JEXEC') or die('Restricted access');

 global $mainframe;

 $document =& JFactory::getDocument();
 $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);
   
$editor = & JFactory :: getEditor();
JHTML::_('behavior.formvalidation');
?>

<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>	
<?php }else{ ?>

<script language="javascript">
function myValidate(f) {
        if (document.formvalidator.isValid(f)) {
                f.check.value='<?php echo JUtility::getToken(); ?>';//send token
        }
        else {
                alert('<?php echo JText::_( 'JS_SOME_VALUES_ARE_NOT_ACCEPTABLE_PLEASE_RETRY');?>');
				return false;
        }
		return true;
}

</script>



<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php if (isset($this->department)&& ($this->department->id == '')){	?>
			<?php echo JText::_('JS_CUR_LOC'); ?> :  <?php echo JText::_('JS_DEPARTMENT'); ?>
		<?php }else{	?>
			<?php echo JText::_('JS_CUR_LOC'); ?> : <a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=mydepartments&Itemid=<?php echo $this->Itemid; ?>" class="curloclnk"><?php echo JText::_('JS_MY_DEPARTMENTS'); ?></a> > <?php echo JText::_('JS_EDIT_DEPARTMENT_INFO'); ?>
		<?php }	?>
	</td></tr>
	<?php } ?>
	<tr><td>
		<?php 
			if (sizeof($this->employerlinks) != 0){
				echo '<div id="toplinks"><ul>';
				foreach($this->employerlinks as $lnk)	{ ?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
						<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
					</span>
				<?php }
				echo '<ul></div>';			
			}
		?>
	</td></tr>	
	<tr><td height="3"></td></tr>
	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php echo JText::_('JS_DEPARTMENT_INFO'); ?>
	</td></tr>
	<tr><td height="10"></td></tr>
</table>
<?php
if ($this->userrole->rolefor == 1) { // employer

?>
<form action="index.php" method="post" name="adminForm" id="adminForm" class="form-validate"  onSubmit="return myValidate(this);">
 <table cellpadding="5" cellspacing="0" border="0" width="100%" >
 					<tr>
			       <td valign="top" align="right"><label id="companyidmsg" for="companyid"><?php echo JText::_('JS_COMPANY'); ?></label>&nbsp;<font color="red">*</font></td>
			        <td ><?php echo $this->lists['companies']; ?></td>
			      	</tr>
					<tr>
			        <td  align="right"><label id="namemsg" for="name"><?php echo JText::_('JS_DEPARTMENT_NAME'); ?></label>&nbsp;<font color="red">*</font></td>
			         <td ><input class="inputbox required" type="text" name="name" id="name"  value="<?php if(isset($this->department)) echo $this->department->name; ?>" />
			        </td></tr>
			      	<tr>
					<td colspan="2" valign="top" align="center" ><label id="descriptionmsg" for="description"><strong><?php echo JText::_('JS_DESCRIPTION'); ?></strong></label></td>
					</tr>
					<tr>
					<td colspan="2" align="center">
					<?php
						$editor =& JFactory::getEditor();
						if(isset($this->department))
							echo $editor->display('description', $this->department->description, '550', '300', '60', '20', false);
						else
							echo $editor->display('description', '', '550', '300', '60', '20', false);

					?>	
					</td>
					</tr>
					
					<tr><td colspan="2" height="10"></td></tr>
					<tr>
						<td colspan="2" align="center">
							<input type="submit"  class="button" value="<?php echo JText::_('JS_SAVE'); ?>"/>


			</td></tr>
		
					
					
 </table> 
			
			<?php
				if(isset($this->department)) {
					if (($this->department->created=='0000-00-00 00:00:00') || ($this->department->created==''))
						$curdate = date('Y-m-d H:i:s');
					else $curdate = $this->department->created;
				}else $curdate = date('Y-m-d H:i:s');
			?>
                <input type="hidden" name="created" value="<?php echo $curdate; ?>" />
		 <input type="hidden" name="uid" value="<?php echo $this->uid; ?>" />
		 <input type="hidden" name="option" value="<?php echo $this->option; ?>" />
		 <input type="hidden" name="task" value="savedepartment" />
		 <input type="hidden" name="Itemid" id="Itemid" value="<?php echo $this->Itemid; ?>" />
		<input type="hidden" name="id" value="<?php if(isset($this->department)) echo $this->department->id; ?>" /> 
</form>
		
<?php 

} else{
	echo JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW');
}
}
?>
<div width="100%">
<?php include_once('components/com_wrecruit/views/fr_jscr.php'); ?>
</div>
